<template>
  <div>
    <!-- 没有图片 -->
    <van-cell v-if="type === 0" :title="articleInfo.title" :label="label" />
    <!-- 一张图片 -->
    <van-cell v-else-if="type === 1" :title="articleInfo.title" :label="label">
      <van-image width="100" height="100" :src="articleInfo.cover?.images[0]" />
    </van-cell>
    <!-- 三张图片 -->
    <van-cell v-else :title="articleInfo.title">
      <template #label>
        <van-image
          width="100"
          height="100"
          v-for="(item, index) in articleInfo.cover?.images"
          :key="index"
          :src="item"
        />
        <!-- 文本 -->
        <span>{{ label }}</span>
      </template>
    </van-cell>
  </div>
</template>

<script>
import dayjs from '@/utils/dayjs'
export default {
  name: '',
  components: {},
  props: {
    // 默认值：如果是基本数据类型直接给
    // 复杂数据类型，以函数的返回值的给值
    articleInfo: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {}
  },
  computed: {
    type() {
      return this.articleInfo.cober?.type
    },
    label() {
      const { aut_name, pubdate, comm_count } = this.articleInfo
      return `${aut_name} ${dayjs(pubdate).fromNow()} ${comm_count}`
    }
  },
  watch: {},
  created() {},
  methods: {}
}
</script>

<style scoped></style>
